package com.gp.node;

import com.stock.StockData;
import com.utils.CONST;
import com.utils.Random;

// this class represent IValue nodes with const value 
// override functions description can be found at the interface IValue
public class Const extends IValue {
	
	private static final long serialVersionUID = -1882617678896070690L;
	// the node value
	public double value;
	
	// c'tor - set given value
	public Const(double value) {
		this.value = value;
	}
	
	// c'tor - set random value
	public Const() {
		this.value = Random.nextInt(CONST.CONST_MAX);
	}
	
	@Override
	public double getValue(StockData stock) {
		return value;
	}

	@Override
	public INode createNew()  {
		return new Const();
	}
	
	@Override
	public INode copy() {
		return new Const(value);
	}	
	
	@Override
	public String print(StockData stock) {
		return String.valueOf(value);
	}
	
	@Override
	public String print() {
		return  String.valueOf(value);
	}
	
}
